package day_2023_7_to_10;

import java.util.HashMap;
import java.util.Map;

/**
 * @author haomin
 * @date 2023/07/23 21:49
 **/
public class Day_7_22 {
    class Solution {
        public int[] twoSum(int[] nums, int target) {
            Map<Integer, Integer> map = new HashMap<>();
            for(int i : nums) {
                if(map.containsKey(i)) {
                    return new int[]{i, map.get(i)};
                } else {
                    map.put(target-i,i);
                }
            }
            return new int[0];
        }
    }
}